package com.hnevc.xiewanguang;

public class Example03 {
    public static void main(String[] args) {
     add();
    }
    //增
    public static void add(){
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("123456"); //在字符串末尾出添加
        System.out.println(stringBuffer);
        stringBuffer.insert(3,",");
        System.out.println(stringBuffer);
    }
    //删
    public  static void remove(){
        StringBuffer stringBuffer = new StringBuffer("123,456");
        stringBuffer.delete(3,4);//删除指定范围
        System.out.println(stringBuffer);
        stringBuffer.deleteCharAt(3);//删除指定位置
        System.out.println(stringBuffer);
        stringBuffer.delete(0,stringBuffer.length());//清空缓冲区
        System.out.println(stringBuffer);
    }
    //改
    public static void alter(){
        StringBuffer stringBuffer = new StringBuffer("123456");
        stringBuffer.setCharAt(2,'4');
        System.out.println(stringBuffer);
        stringBuffer.replace(2,4,"56");
        System.out.println(stringBuffer);

    }
}
